package flc.ast.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.LineAdapter;
import flc.ast.adapter.ProtectionRecordAdapter;
import flc.ast.bean.MyLineBean;
import flc.ast.bean.MyProtectionBean;
import flc.ast.databinding.ActivityProtectionRecordBinding;
import flc.ast.utils.AppSpUtils;
import stark.common.basic.event.EventStatProxy;

public class ProtectionRecordActivity extends BaseAc<ActivityProtectionRecordBinding> {

    private List<MyProtectionBean> listShow = new ArrayList<>();
    private ProtectionRecordAdapter recordAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_protection_record;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);

        mDataBinding.ivProtectionRecordBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.rvRecordList.setLayoutManager(new LinearLayoutManager(mContext));
        recordAdapter = new ProtectionRecordAdapter();
        mDataBinding.rvRecordList.setAdapter(recordAdapter);
    }

    @Override
    protected void initData() {
        getData();
    }

    private void getData() {
        listShow.clear();
        listShow = AppSpUtils.getProtectionRecordList();
        if (listShow != null && listShow.size() != 0) {
            recordAdapter.setList(listShow);
            mDataBinding.rvRecordList.setVisibility(View.VISIBLE);
            mDataBinding.tvRecordNoData.setVisibility(View.GONE);
        } else {
            mDataBinding.rvRecordList.setVisibility(View.GONE);
            mDataBinding.tvRecordNoData.setVisibility(View.VISIBLE);
        }
    }

}